﻿@model SuperiorModel.PagingResult
<div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage">
    <span class="layui-laypage-count">
        共 @Model.TotalCount 条
    </span>
    @if (Model.HasPreviousPage)
    {
        <a href="javascript:;" class="layui-laypage-prev" >
            上一页
        </a>
    }
    else
    {
        <a href="javascript:;" class="layui-laypage-prev layui-disabled" >
            上一页
        </a>
    }

    @{
        var fromIndex = Math.Max(Model.PageIndex - 5, 0);
        var maxPageIndex = Math.Max(Model.TotalPages - 1, 0);
        var toIndex = Math.Min(Model.PageIndex + 4, maxPageIndex);
        while (toIndex - fromIndex < 9)
        {
            if (toIndex < maxPageIndex)
            {
                toIndex++;
            }
            else if (fromIndex > 0)
            {
                fromIndex--;
            }
            else
            {
                break;
            }
        }
    }
    @for (int i = fromIndex; i <= toIndex; i++)
    {

        if (Model.PageIndex == i)
        {
            <span class="layui-laypage-curr">
                <em class="layui-laypage-em">
                </em>
                <em id="currentPage">
                    @(i + 1)
                </em>
            </span>
        }
        else
        {
            <a href="javascript:;" pageIndex="@i">
                @(i + 1)
            </a>
        }
    }
    @if (Model.HasNextPage)
    {
        <a href="javascript:;" class="layui-laypage-next" >
            下一页
        </a>
    }
    else
    {
        <a href="javascript:;" class="layui-laypage-next layui-disabled" >
            下一页
        </a>
    }

    <span class="layui-laypage-limits">
        
                @Model.PageSize 条/页
    
    </span>
    <a href="javascript:;"  class="layui-laypage-refresh">
        <i class="layui-icon layui-icon-refresh">
        </i>
    </a>
    <span class="layui-laypage-skip">
        到第
        <input type="text" id="pageGoIndex" maxpage="@(Model.TotalPages)" value="@(Model.PageIndex+1)" class="layui-input">
        页
        <button type="button" id="_btn_topage" class="layui-laypage-btn">
            确定
        </button>
    </span>
</div>